home *** CD-ROM | disk | FTP | other *** search
/ Aminet 28 / Aminet 28 (1998)(GTI - Schatztruhe)[!][Dec 1998].iso / Aminet / util / rexx / mimig.lha / mimig / mimig.rexx < prev   
Encoding:
OS/2 REXX Batch file  |  1998-09-16  |  3.9 KB  |  149 lines

  1. /* $VER: MIMIG 1.0 (16.9.98) */
  2. /* $AUTH: Kai Weber <kai.weber@gmx.net> */
  3.  
  4. PATH_MUIREXX   =  "sys:rexxc/MuiRexx"
  5. PATH_NETSTAT   =  "MIAMI:MiamiNetStat"
  6. WAIT_SECS      =  2
  7.  
  8. /* - DO NOT CHANGE IF YOU DONT KNOW WHAT YOU DO ----------------------------- */
  9.  
  10. NL = '0a'x
  11. options results
  12.  
  13. /* TAG ID definitions */
  14. MUIA_List_Format             = 0x80423c0a
  15. MUIM_Application_OpenConfigWindow = 0x804299ba
  16. MUIV_List_Insert_Bottom         = -3
  17. MUIA_List_Quiet           = 0x8042d8c7
  18. MUIA_List_Entries         = 0x80421654
  19. MUIV_List_Select_Off      =  0
  20.  
  21. /* - START ------------------------------------------------------------------ */
  22.  
  23. if ~show('l', "rexxreqtools.library") then do;call addlib('rexxreqtools.library',0,-30,0);end
  24.  
  25. if ~show('ports',MIMIG) then do
  26.     if exists(PATH_MUIREXX) then do
  27.         address command 'run <nil: >nil: 'PATH_MUIREXX' PORT MIMIG'
  28.     end
  29.     else do
  30.         call rtezrequest( "Can not find MUIRexx!"|| NL ||"Please go and configure"|| NL ||,
  31.                           "the script or your system","OK","Fatal Error",'RT_REQPOS=REQPOS_CENTERSCR RTGS_WIDTH=150' )
  32.         exit
  33.     end
  34.     address command 'waitforport 'MIMIG
  35. end
  36.  
  37. /* - MAIN -------------------------------------------------------------------- */
  38.  
  39. m1 = 0     /* Miami active var  */
  40. m2 = 0     /* Miami online var  */
  41. m3 = 0     /* Miami offline var */
  42.  
  43. main:
  44. call buildwin
  45. do forever
  46.     call testonline
  47.     call read
  48. end
  49. exit
  50.  
  51. /* - BUILDWIN ---------------------------------------------------------------- */
  52.  
  53. buildwin:
  54.  
  55. address MIMIG
  56.  
  57. window ID MAIN TITLE '"Mimig 1.0 © 1998 by Kai Weber"' COMMAND "quit" PORT MIMIG
  58.     group FRAME LABEL 'Output'
  59.         list ID LST TITLE '"\033b\033cNo.,\033b\033cProtocol,\033b\033cRecv-Q,\033b\033cSend-Q,\033b\033cLocal Adress,\033b\033cForeign Address,\033b\033c(state)"' ATTRS MUIA_List_Format '"P=\033c BAR,P=\033r BAR,P=\033r BAR,BAR,BAR,BAR,"' MUIV_List_Select_Off
  60.     endgroup
  61.     space 2
  62.     group FRAME LABEL 'Status'
  63.         text ID TXT
  64.     endgroup
  65. endwindow
  66. return
  67.  
  68.  
  69. /* - READ -------------------------------------------------------------------- */
  70.  
  71. read:
  72. address command PATH_NETSTAT '>t:netstat.txt -N'
  73. if open(file,"t:netstat.txt",'R') THEN DO
  74.     i=0
  75.     call testmimig
  76.     address MIMIG
  77.     list ID LST STRING
  78.     do until eof(file)
  79.         line = readln(file)
  80.         if substr(line,1,3) = "Act" | substr(line,1,3)="Pro" | substr(line,1,1) =" " then nop
  81.         else do
  82.         i=i+1
  83.         parse var line with 1 name +5 With 7 recvq +6 with 14 sendq +6 with 22 locad +21 with 45 forad +21 with 68 stat +11
  84.         call testmimig
  85.         list id LST POS MUIV_List_Insert_Bottom INSERT STRING i','name','recvq','sendq','locad','forad','stat
  86.         end
  87.     end
  88. end
  89. if close(file) then address command 'wait ' WAIT_SECS 'sec'
  90. return
  91.  
  92. /* - TESTMIAMI -------------------------------------------------------------- */
  93.  
  94. testmiami:
  95.  
  96.     do forever
  97.         call testmimig
  98.         if ~show('port',MIAMI.1) then do
  99.             if m1 = 0 then do
  100.                 address MIMIG
  101.                 text ID TXT LABEL 'Miami not found.'
  102.                 m1 = 1
  103.                 m2 = 0
  104.                 m3 = 0
  105.             end
  106.             nop
  107.         end
  108.         else do
  109.             leave
  110.         end
  111.     end
  112.  
  113. return
  114.  
  115. /* - TESTONLINE ------------------------------------------------------------- */
  116.  
  117. testonline:
  118.  
  119.     do forever
  120.         call testmiami
  121.         address MIAMI.1
  122.         IsOnline
  123.         if rc=0 then do
  124.             if m3 = 0 then do
  125.             address MIMIG
  126.             text ID TXT LABEL 'Miami is offine.'
  127.             m3 = 1
  128.             m2 = 0
  129.             end
  130.             nop
  131.         end
  132.         else do
  133.             if m2 = 0 then do
  134.             address MIMIG
  135.             text ID TXT LABEL 'Miami is online.'
  136.             m2 = 1
  137.             m3 = 0
  138.             end
  139.             leave
  140.         end
  141.     end
  142. return
  143.  
  144. /* - TESTMIMIG -------------------------------------------------------------- */
  145.  
  146. testmimig:
  147. if ~show('port',MIMIG) then exit
  148. return
  149.